#include <iostream>
#include "queue.h"
#include "RBTree.h"
#include "cyber_dash_string.h"

using namespace std;

void TestGetSize()
{
    LinkQueue<string> queue;

    string item[12] =
    {
        "反反复复月光太迷惑", "却还挂在天一边嘲笑我", "过分在意别人给的冷漠", "我该开始为自己而活",
        "轻轻把沉重的过去上锁", "离开曾经被你溺爱的我", "离开那离不开你的懦弱", "继续往前找另一个自我",
        "终于把心痛的过去挣脱", "离开自己看清真假对错", "不是飞蛾没资格扑火", "伤到了底总有清醒时候"
    };

    for (int i = 0; i < 12; i++)
    {
        cout<<"enqueue: "<<item[i]<<endl;
        queue.EnQueue(item[i]);
    }
    cout<<endl<<"queue size: "<<queue.GetSize()<<endl;
}


void stringTest()
{

  // test Find
  CyberDashString pattern1("aab12aab12aab");
  CyberDashString pattern2("aab12aab12aab");
  CyberDashString pattern3("a");
  CyberDashString pattern4("xyz");
  CyberDashString pattern5("xyzzz");
  CyberDashString test_str6("12aab12aab12aabxyz");
  CyberDashString test_str7("12aab12aab12aabxyz");

  // test KMPFind
  int find_pos;
  find_pos = test_str6.KMPFind(pattern1, 0);
  cout<<"KMP find_pos1:"<<find_pos<<endl;
  find_pos = test_str6.KMPFind(pattern2, 0);
  cout<<"KMP find_pos2:"<<find_pos<<endl;
  find_pos = test_str6.KMPFind(pattern3, 0);
  cout<<"KMP find_pos3:"<<find_pos<<endl;
  find_pos = test_str6.KMPFind(pattern4, 0);
  cout<<"KMP find_pos4:"<<find_pos<<endl;
  find_pos = test_str6.KMPFind(pattern5, 0);
  cout<<"KMP find_pos5:"<<find_pos<<endl<<endl;

  // test KMPFind_minified
  find_pos = test_str7.KMPFind_minified(pattern1, 0);
  cout<<"KMP_minified find_pos1:"<<find_pos<<endl;
  find_pos = test_str7.KMPFind_minified(pattern2, 0);
  cout<<"KMP_minified find_pos2:"<<find_pos<<endl;
  find_pos = test_str7.KMPFind_minified(pattern3, 0);
  cout<<"KMP_minified find_pos3:"<<find_pos<<endl;
  find_pos = test_str7.KMPFind_minified(pattern4, 0);
  cout<<"KMP_minified find_pos4:"<<find_pos<<endl;
  find_pos = test_str6.KMPFind_minified(pattern5, 0);
  cout<<"KMP find_pos5:"<<find_pos<<endl<<endl;
}

int main(int argc, char *argv[])
{
    TestGetSize();
    RBTreeTest();   //红黑树测试代码
    stringTest();
    return 0;
}
